package com.itheima.threadDemo;
//利用Runnable来进行多线程的构建
public class Demo2 {
    public static void main(String[] args) {
        //获取当前线程
        String name = Thread.currentThread().getName();
        System.out.println(name);
        //创建对象
        MyRunnable mr = new MyRunnable();
        //将mr作为参数传递到Thread当中
        Thread t1 = new Thread(mr);
        Thread t2 = new Thread(mr);
        t1.setName("小明");
        t2.setName("小强");
        t1.start();
        t2.start();
    }
}
class MyRunnable implements Runnable{

    @Override
    public void run() {
        //循环
        for (int i = 0; i < 50; i++) {
            //获取当前线程名称
            System.out.println(Thread.currentThread().getName()+"线程启动了"+i);
        }
    }
}